package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Statistics;
import com.itheima.service.StatisticsService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/submitInfo")
public class SubmitInfoController {

    @Reference
    private StatisticsService statisticsService;

    @RequestMapping("/submit")
    public Result add(@RequestBody Statistics statistics){
        try {
            statisticsService.submitInfo(statistics);
            return new Result(true, MessageConstant.SUBMIT_FORM_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.SUBMIT_FORM_FAILED);
        }
    }
}
